home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
8_5.lha
/
8_5
/
fgets.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
463b
|
25 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ read a string up to and including a newline
include <string.h>
har *fgets(char *buf, int length, FILE *f)
if ((f->mode == input) &&
(f->in->get(buf, length-2)))
{
char c = 0;
f->in->get(c);
if (c == '\n')
{
char *nl = buf + strlen(buf);
*nl++ = '\n';
*nl = 0;
}
return buf;
}
return NULL;